﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Cherry.Agile.Scheduler.Configuration
{
    public class QuartzSection : ConfigurationSection
    {
        internal const string SECTION_NAME = "quartz";

        [ConfigurationProperty("settings", Options = ConfigurationPropertyOptions.None)]
        public SettingElementCollection Settings
        {
            get { return (SettingElementCollection)base["settings"]; }

        }

        [ConfigurationProperty("schedulers", Options = ConfigurationPropertyOptions.None)]
        public SchedulerElementCollection Schedulers
        {
            get { return (SchedulerElementCollection)base["schedulers"]; }

        }
    }


    /// <summary>
    /// 
    /// </summary>
    public class SettingElementCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// 
        /// </summary>
        public SettingElementCollection()
        {
            base.AddElementName = "setting";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new SettingElement();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            var el = (element as SettingElement);
            return string.Format("{0}", el.Name);
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public class SettingElement : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return (string)base["name"]; }
            set { base["name"] = value; }

        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("value", IsRequired = false)]
        public string Value
        {
            get { return (string)base["value"]; }
            set { base["value"] = value; }
        }




    }
}
